a = input("Введите скобочную последовательность:")
s = ''
s1 = ''
k = 0
for i in range (len(a)):
    if a[i] in '([{<>}])':
        s = s+a[i]
for i in range (len(s)):
    if s[i] in '([{<':
        s1 = s1+s[i]
    elif len(s1)>0 and s[i]==')' and s1[-1]=='(':
        s1 = s1[:-1]
    elif len(s1)>0 and s[i]==']' and s1[-1]=='[':
        s1 = s1[:-1]
    elif len(s1)>0 and s[i]=='}' and s1[-1]=='{':
        s1 = s1[:-1]
    elif len(s1)>0 and s[i]=='>' and s1[-1]=='<':
        s1 = s1[:-1]
    else:
        k+=1 
        break 
if s1 == '' and k == 0:
    print('True')
else:
    print('False')